package com.andy.beef.ui.main.api

import com.andy.beef.ui.main.bean.EnterInfoBean
import com.andy.beef.ui.main.bean.FarmCattleBean
import com.andy.module.BASE_BREED
import com.andy.module.BASE_TRADE
import com.andy.module.BASE_WMS
import com.andy.module.network.ApiPagerResponse
import com.andy.module.network.ApiResponse
import com.andy.module.network.RetrofitClient
import com.andy.module.network.SimpleApiService
import retrofit2.http.FieldMap
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST
import retrofit2.http.Url

/**
 * @creator:LuoFan
 * @date:2022/6/8
 * @description:
 */

//双重校验锁式-单例 封装NetApiService 方便直接快速调用简单的接口
val tradeService: TradeApiService by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
    RetrofitClient.getService(TradeApiService::class.java, SimpleApiService.SERVER_URL)
}

interface TradeApiService : SimpleApiService {

    companion object {

        const val URL_UPLOAD_PHOTO = BASE_WMS + "common/file/upload/public-pic"

        const val URL_BREED_UPLOAD_PHOTO = BASE_BREED + "config/common/pic-upload"

        //入场信息列表
        const val URL_ENTER_INFO_LIST = BASE_TRADE + "mobile/cattle-entry/list"

        const val URL_DELETE_ENTER_INFO = BASE_TRADE + "mobile/cattle-entry/del"

        //场内牛只列表
        const val URL_FARM_CATTLE_LIST = BASE_BREED + "mobile/cattle/list"

        //新增牛只
        const val URL_CATTLE_ADD = BASE_BREED + "mobile/cattle/add"

        //新增牛只
        const val URL_CATTLE_EDIT = BASE_BREED + "mobile/cattle/edit"
    }

    /**
     * 获取入场信息列表
     */
    @FormUrlEncoded
    @POST
    suspend fun getEnterInfoList(
        @Url url: String,
        @FieldMap params: HashMap<String, Any>
    ): ApiResponse<ApiPagerResponse<EnterInfoBean>>

    /**
     * 获取场内牛只信息
     */
    @FormUrlEncoded
    @POST
    suspend fun getFarmCattleList(
        @Url url: String,
        @FieldMap params: HashMap<String, Any>
    ): ApiResponse<ApiPagerResponse<FarmCattleBean>>
}